UpdateGWorld
UpdateGWorld Update the offscreen graphics device world
#include <QDOff screen.h> Graphics Devices
GWorldFlags UpdateGWorld( off screenGWorld, pixelDepth, boundsRect, cTable,
aGDevice, flags );
GWorldPtr *off screenGWorld ; Used to return a pointer to a new off screen
graphics world
short pixelDepth ; Pixel resolution of offscreen graphics world. If
set to 0, the device list is rescanned to find the
new deepest device intersecting with the new
boundary rectangle in global screen space
Rect *boundsRect ; Determines offscreen pixel map's size and
coordinate system
CTabHandle cTable ; Handle to the color table to be used (use 0 for
default color table)
GDHandle aGDevice ; Used when the noNewDevice flag is set. If this
field is not NULL, the depth and color table of
the graphics device record specified by
aGDevice are used instead of those specified by
the pixelDepth and cTable fields
GWorldFlags flags ; flags indicating GWorld attributes to change
returns new GWorldFlags attributes
UpdateGWorld is similar to NewGWorld, your application can use it to
change one or more of the offscreen world's attributes.
If the offscreen buffer has been purged, UpdateGWorld re allocates it.
With the flags parameter you can set the keepLocal flag, which keeps the
graphics world data structures in main memory (or returns them if they were
not previously cached), or you can clear it if it was previously set, allowing
the graphics world to be cached on a graphics accelerator card, if present. The
flags can also include a combination of the flags clipPix, ditherPix, and
stretchPix. Some combinations are illegal; the legal uses of these flags are as
follows:
[] (no flags)
clipPix
stretchPix
clipPix, ditherPix
stretchPix, ditherPix
If none of the flags is set, the pixels are not updated.
If clipPix is set, the pixels are updated, with stretching or shrinking if the
boundsRect value has changed. If boundsRect hasn't changed, stretchPix is
equivalent to clipPix.
If stretchPix is set, the pixels are first updated according to the state of
clipPix or stretchPix. They are dithered if necessary.
If ditherPix is set, the pixels are first updated according to the state of
clipPix or stretchPix. They are dithered if necessary.
UpdateGWorld returns a pointer to the new offscreen graphics world in th
off screenGWorld parameter. If off screenGWorld was the current graphics
world and UpdateGWorld changed it, the current graphics world is set to the
updated offscreen graphics world.
The result of UpdateGWorld is a combination of the flags mapPix,
newDepth, alignPix, newRowBytes, reallocPix, clipPix, stretchPix,
ditherPix, and gwFlagErr, which are members of the GWorldFlags set. If
gwFlagErr is set, UpdateGWorld was unsuccessful an off screenGWorld is
left un changed. The result of UpdateGWorld must be coerced to a long integer
and contains one of the following result codes:
Returns: an Error Code; it will be one of
paramErr (-50) Illegal parameter
cDepthErr (-157) Invalid pixel resolution
If UpdateGWorld is successful, the other flags must be interpreted as
follows:
Flag Meaning
mapPix Color table mapping occured
newDepth Pixels were scaled to a different depth
alignPix Pixels were realigned to the screen alignment
newRowBytes The pixel map was recon figured with a new rowBytes
value
reallocPix The offscreen buffer had to be re allocated; your image
was discarded
clipPix Pixels were clipped
stretchPix Pixels were stretched or shrunk
ditherPix Pixels were dithered
UpdateGWorld uses the following algorithm for pixel preservation.
1) If cTable is new, the pixels are mapped to the new color table.
2) If pixelDepth is new, the pixels are scaled to the new pixel depth.
3) If boundsRect is new but has the same size, the pixel map is just realigned
for optimum CopyBits performance.
4) If boundsRect is smaller and clipPix is set, the pixels in the bottom and
right edges are clipped.
5) If boundsRect is bigger and clipPix is set, the bottom and right edges are
un defined.
6) If boundsRect is smaller and stretchPix is set, the pixel map is reduced to
the new size.
7) If boundsRect is bigger and stretchPix is set, the pixel map is stretched to
the new size.
8) If the offscreen buffer was purged, it is re allocated, but the pixels are
lost.